package com.jy.wms.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jy.wms.common.annotions.BaseServiceDescribe;
import com.jy.wms.common.base.BaseService;
import com.jy.wms.common.base.ServiceException;
import com.jy.wms.common.base.SucessException;
import com.jy.wms.dao.WmsLibraryAreaMapper;
import com.jy.wms.pojo.WmsLibraryArea;
import com.jy.wms.pojo.WmsWarehouse;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @ClassName: WmsLibraryAreaService.java
* @Description: TODO(这里用一句话描述这个类的作用)
* @Author yjs
* @Date Tue Aug 29 15:59:22 GMT+08:00 2017
*/

@Service
public class WmsLibraryAreaService extends BaseService<WmsLibraryAreaMapper,WmsLibraryArea> {

 /**
 * 插入一条记录
 * @param entity 实体对象
 * @return int
 */
 @BaseServiceDescribe(moduleName = "库区管理",btnName = "新增库区")
public void baseInsert( WmsLibraryArea entity) throws Exception {
     Integer i=dao.baseInsert( entity );
     if(i>0){
         throw new SucessException("新增库区信息成功");
     }else{
         throw new ServiceException("新增库区信息失败");
     }
}

    /**
     * 添加前去除重复
     * @param mc
     * @param ckid
     * @param dm
     * @return
     */
    public WmsLibraryArea searchADD(String mc,String ckid,String dm){
        return dao.searchADD(mc, ckid, dm);
    }

    /**
     * 编辑库区查询去重
     *
     * @param mc
     * @param ckid
     * @param dm
     * @param id
     * @return
     */
    public WmsLibraryArea searchEdit(String mc, String ckid, String dm, String id) {
        return dao.searchEdit(mc, ckid, dm, id);
    }

    /**
     * 编辑库区保存
     *
     * @param entity
     * @return
     */
    public void editWmsLibraryArea(WmsLibraryArea entity) throws Exception {
        Integer i = dao.editWmsLibraryArea(entity);
        if (i > 0) {
            throw new SucessException("编辑库区信息成功");
        } else {
            throw new ServiceException("编辑库区信息失败");
        }
    }
/**
* 插入一条记录（匹配有值的字段）
* @param entity 实体对象
* @return int
*/
public Integer baseInsertSelective( WmsLibraryArea entity){
     return dao.baseInsertSelective( entity);
}

/**
* 删除（根据主键ID删除）
* @param id 主键
* @return int
*/
public Integer baseDeleteByPrimaryKey( String id){
     return dao.baseDeleteByPrimaryKey( id);
}

/**
* 删除（根据ID 批量删除）
* @param idList 主键ID列表
* @return int
*/
public Integer baseDeleteBathPrimaryKeys( List<String> idList){
     return dao.baseDeleteBathPrimaryKeys( idList);
}

/**
* 分页查询
* @param entity 实体
* @return Page<WmsLibraryArea>
*/
@BaseServiceDescribe(moduleName = "库区管理",btnName = "分页查询库区")
public Page<WmsLibraryArea> baseSelectPage(WmsLibraryArea entity) throws ServiceException {
    try{
        PageHelper.startPage(entity.getPage(), entity.getRows());
        return (Page<WmsLibraryArea>)dao.baseSelectPage( entity);
    }catch(Exception e){
        throw new ServiceException("查询库区列表失败",e);
    }
}

/**
* 查询（根据主键ID查询）
* @param id 主键ID
* @return WmsLibraryArea
 */
@BaseServiceDescribe(moduleName = "库区管理", btnName = "编辑查询库区信息")
public WmsLibraryArea baseSelectByPrimaryKey(String id) throws Exception {
    return dao.baseSelectByPrimaryKey(id);
}

    /**
     * 查询当前仓库信息
     * @return
     */
public WmsWarehouse addSearchCK(){
    return dao.addSearchCK();
}
}
